package gui;

import gui.data.SavedResultsGui;
import gui.data.WelcomeGui;
import gui.data.D2.CircleInputGui;
import gui.data.D2.PointsIn2DInputGui;
import gui.data.D2.PolygonInputGui;
import gui.data.D2.QuadrangleInputGui;
import gui.data.D2.TriangleInputGui;
import gui.data.D3.PointsIn3DInputGui;
import gui.data.D3.PolyhedronInputGui;
import gui.data.D3.PyramidInputGui;
import gui.data.D3.SphereInputGui;
import gui.data.others.ConverterGui;
import gui.data.others.SingleInputGui;
import gui.navigation.D2Gui;
import gui.navigation.D3Gui;
import gui.navigation.MainMenuGui;
import gui.navigation.OthersGui;

import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Dimension;

import javax.swing.JFrame;
import javax.swing.JPanel;

public class MyFrame extends JFrame{
	
	public final static String MAIN = "NAV_MAIN";
	public final static String OTHERS = "NAV_OTHERS";
	public final static String D2 = "NAV_2D";
	public final static String D3 = "NAV_3D";
	
	public final static String WELCOME = "DATA_WELCOME";
	public final static String PI = "DATA_PI";	
	public final static String FIBBO = "DATA_FIBBO";
	public final static String PRIME = "DATA_PRIME";
	public final static String DIST2D = "DATA_DIST2D";
	public final static String CIRCLE = "DATA_CIRCLE";
	public final static String POLYGON = "DATA_POLYGON";
	public final static String TRIANGLE = "DATA_TRIANGLE";
	public final static String QUADRANGLE = "DATA_QUADRANGLE";
	public final static String DIST3D = "DATA_DIST3D";
	public final static String SPHERE = "DATA_SPHERE";
	public final static String POLYHEDRON = "DATA_POLYHED";
	public final static String PYRAMID = "DATA_PYRAMID";
	public final static String CONVERT = "DATA_CONVERT";
	public final static String SAVED = "DATA_SAVED";
	
	public JPanel navigation;
	public JPanel data;
	public CardLayout navLayout;
	public CardLayout dataLayout;
	
	public String shownNavPanel = "";
	public String shownDataPanel = "";
	
	public MyFrame(){
		navLayout = new CardLayout();
		dataLayout = new CardLayout();
		
		navigation = new JPanel(navLayout);
		data = new JPanel(dataLayout);
		
		this.setTitle("Valemikalkulaator");
		this.setSize(725, 500);
		this.setResizable(false);
		this.setDefaultCloseOperation(EXIT_ON_CLOSE);
		
		navigation.add(new MainMenuGui(this), MAIN);
		navigation.add(new OthersGui(this), OTHERS);
		navigation.add(new D2Gui(this), D2);
		navigation.add(new D3Gui(this), D3);
		
		data.add(new WelcomeGui(), WELCOME);
		data.add(new SingleInputGui(1, this), PI);
		data.add(new SingleInputGui(2, this), FIBBO);
		data.add(new SingleInputGui(3, this), PRIME);
		data.add(new PointsIn2DInputGui(this), DIST2D);
		data.add(new CircleInputGui(this), CIRCLE);
		data.add(new PolygonInputGui(this), POLYGON);
		data.add(new TriangleInputGui(this), TRIANGLE);
		data.add(new QuadrangleInputGui(this), QUADRANGLE);
		data.add(new PointsIn3DInputGui(this), DIST3D);
		data.add(new SphereInputGui(this), SPHERE);
		data.add(new PolyhedronInputGui(this), POLYHEDRON);
		data.add(new PyramidInputGui(this), PYRAMID);
		data.add(new ConverterGui(), CONVERT);
		data.add(new SavedResultsGui(), SAVED);
		
		navigation.setPreferredSize(new Dimension(200, 500));
		data.setPreferredSize(new Dimension(500, 500));
		
		add(navigation, BorderLayout.WEST);
		add(data, BorderLayout.EAST);
		
		setNavigationPanel(MAIN);
		setDataPanel(WELCOME);
		
		this.setVisible(true);
	}
	
	public void setNavigationPanel(String id){
		navLayout.show(navigation, id);
		shownNavPanel = id;
	}
	
	public void setDataPanel(String id){
		dataLayout.show(data, id);
		shownDataPanel = id;
	}
	
	public void setNavigationPanel(JPanel panel, String id){
		navigation.add(panel, id);
		navLayout.show(navigation, id);
		shownNavPanel = id;
	}
	
	public void setDataPanel(JPanel panel, String id){
		data.add(panel, id);
		dataLayout.show(data, id);
		shownDataPanel = id;
	}
}
